# $Id: PKGBUILD 164259 2012-07-29 01:13:10Z dreisner $
# Maintainer: Dave Reisner <dreisner@archlinux.org>
# Contributor: Thomas Baechler <thomas@archlinux.org>

pkgname=vpnc
_vpncver=0.5.3
_git=1b65c39e3cdebb89ce5c75f05d44a0519a67ede6
pkgver=$_vpncver.svn516
pkgrel=3
pkgdesc="VPN client for cisco3000 VPN Concentrators"
url="http://www.unix-ag.uni-kl.de/~massar/vpnc/"
license=('GPL')
depends=('libgcrypt' 'openssl' 'iproute2')
optdepends=('openresolv: Let vpnc manage resolv.conf')
arch=('i686' 'x86_64')
source=("ftp://ftp.archlinux.org/other/$pkgname/$pkgname-$pkgver.tar.xz"
        "http://git.infradead.org/users/dwmw2/vpnc-scripts.git/blob_plain/$_git:/vpnc-script"
        'vpnc.conf')
backup=('etc/vpnc/default.conf')
md5sums=('2118c5ccc464250c0892be57dbfabdf7'
         '6293c15ef6e7a3365ed7add5e336b806'
         'a3f4e0cc682f437e310a1c86ae198e45')

mktarball() {
  [[ -d tarball ]] || mkdir tarball

  pushd tarball

  svn co http://svn.unix-ag.uni-kl.de/vpnc/trunk
  _svnrev=$(cd trunk >/dev/null; svn info | awk '/^Revision:/ { print $2 }')

  find trunk/ -type d -name .svn -exec rm -rf {} +
  mv trunk "$pkgname-$_vpncver.svn$_svnrev"
  tar cJf "../$pkgname-$_vpncver.svn$_svnrev.tar.xz" "$pkgname-$_vpncver.svn$_svnrev/"

  popd
  rm -rf tarball
}

build() {
  cd "$pkgname-$pkgver"

  # Build hybrid support
  sed -i 's|^#OPENSSL|OPENSSL|g' Makefile

  # fix resolvconf location for community/openresolv
  sed -i 's|/sbin/resolvconf|/usr&|g' "$srcdir/vpnc-script"

  make
}

package() {
  cd "$pkgname-$pkgver"

  make DESTDIR="$pkgdir" PREFIX=/usr install

  install -Dm644 "$srcdir"/vpnc.conf "$pkgdir"/etc/vpnc/default.conf
  install -Dm755 "$srcdir"/vpnc-script "$pkgdir"/etc/vpnc/vpnc-script
}
